package com.example.spring.rabbitmq.producer;

import cn.hutool.json.JSONUtil;
import com.example.spring.rabbitmq.dto.AfterSaleAccountChangeResultDTO;
import com.example.spring.rabbitmq.enums.MQSendEnum;
import com.example.spring.rabbitmq.message.WorkOrderCreateMessageReq;
import com.example.spring.rabbitmq.util.RabbitMqUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @Description
 * @Author zhengmw
 * @Data 2024/5/16 9:24
 */
@Component
public class RabbitmqProducer {
    @Resource
    private RabbitMqUtils rabbitMqUtils;

    /**
     * @Description 发送消息
     * @Param resultDTO 需要发送的消息
     * @Return void
     *
     * @Author zhengmw
     * @Date 2024/5/17 10:13
     */
    public void send(AfterSaleAccountChangeResultDTO resultDTO) {
        rabbitMqUtils.sendMessage(MQSendEnum.RENT_CARD_CHANGE_RESULT, JSONUtil.toJsonStr(resultDTO));
    }

    /**
     * @Description 发送工单消息
     *
     * @Param messageResp
     * @Return void
     * @Author zhengmw
     * @Date 2024/5/29 18:11
     */
    public void sendWorkOrder(WorkOrderCreateMessageReq messageReq) {
        rabbitMqUtils.sendMessage(MQSendEnum.WORD_ORDER_CREATE, JSONUtil.toJsonStr(messageReq));
    }
}
